package ae.pcfc.etks.online.itworx.ehs.web.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.ForeignKey;

@Entity
@Table(name = "T_EHS_AUDIT")
@SequenceGenerator(name = "EHS_AUDIT_ID_SEQ", sequenceName = "EHS_AUDIT_ID_SEQ", initialValue = 1, allocationSize = 1)
public class Audit extends AuditableEntity implements Serializable {

	@Id
	@Column(name = "EHS_AUDIT_ID")
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "EHS_AUDIT_ID_SEQ")
	private long id;
	@Temporal(TemporalType.DATE)
	@Column(name = "ACTION_DATE", nullable = false)
	private Date actionDate;
	@Column(name = "USERNAME", nullable = false, length = 50)
	private String username;
	@Column(name = "METHOD", nullable = false, length = 50)
	private String method;
	@OneToOne
	@ForeignKey(name = "FK_AUDIT_REQUEST", inverseName = "FK_REQUEST_AUDIT")
	@JoinColumn(name = "EHS_REQUEST_ID")
	private Request request;
	@Column(name = "USER_TYPE", nullable = false, length = 50)
	private String userType;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public Date getDate() {
		return actionDate;
	}

	public void setDate(Date actionDate) {
		this.actionDate = actionDate;
	}

	public String getUser() {
		return username;
	}

	public void setUser(String username) {
		this.username = username;
	}

	public String getMethod() {
		return method;
	}

	public void setMethod(String method) {
		this.method = method;
	}

	public Request getRequestId() {
		return request;
	}

	public void setRequestId(Request requestId) {
		this.request = requestId;
	}

	public String getUserType() {
		return userType;
	}

	public void setUserType(String userType) {
		this.userType = userType;
	}

}
